<template>
  <div>
    <el-dialog
      title="处理结果"
      :visible.sync="addEditIsDialog_c"
      @close="resetForm('formName')"
      width="800px"
    >
      <el-form
        :model="ruleForm"
        :rules="rules"
        ref="formName"
        label-width="120px"
        class="demo-ruleForm"
        :class="{ 'form-rules-show': seeType }"
      >
        <el-row>
          <el-col :span="24">
            <el-form-item label="处理内容：" prop="dealContent">
              <el-input
                v-model="ruleForm.dealContent"
                placeholder="请输入处理内容"
                clearable
                maxlength="200"
                type="textarea"
                :rows="2"
                show-word-limit
                :disabled="seeType"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="处理图片：" prop="dealImagesArr">
              <el-image
                v-for="(item, index) in ruleForm.dealImagesArr"
                :key="index"
                style="height: 50px"
                :src="item"
                fit="contain"
              >
              </el-image>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="处理人：" prop="dealUserName">
              <el-input
                v-model="ruleForm.dealUserName"
                placeholder="请输入处理人"
                clearable
                maxlength="50"
                show-word-limit
                :disabled="seeType"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="处理时间：" prop="createDate">
              <el-input
                v-model="ruleForm.createDate"
                placeholder="请输入处理时间"
                clearable
                maxlength="50"
                show-word-limit
                :disabled="seeType"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="resetForm('formName')">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script type="text/ecmascript-6">
import { getDataTaskResult } from "@/api/inspect";

export default {
  props: {
    addEditId: {
      type: String,
      default: "",
    },
    addEditStatus: {
      type: String,
      default: "add",
    },
    addEditIsDialog: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    return {
      ruleForm: {
        // 表单字段
        id: "",
        dealUserName: "",
        dealContent: "",
        dealImagesArr: [],
        dealImages: "",
      },
      rules: {
        // 表单规则
      },
      addEditIsDialog_c: false, // 弹窗是否显示
      seeType: false, // 是否禁用
    };
  },
  watch: {
    addEditIsDialog(val) {
      this.addEditIsDialog_c = val;
      if (this.addEditIsDialog_c) {
        // 查看
        if (this.addEditStatus == "see") {
          this.ruleForm.id = this.addEditId;
          this.seeType = true;
          this.getDetail();
        }
      }
    },
  },
  methods: {
    // 详情
    getDetail() {
      getDataTaskResult({ taskType: 0, taskId: this.addEditId }).then((res) => {
        if (res.code == 200) {
          res.data.dealImagesArr =
            res.data.dealImages != undefined
              ? res.data.dealImages.split(",")
              : [];
          this.ruleForm = res.data;
        }
      });
    },
    // 取消
    resetForm(formName) {
      this.$refs[formName].resetFields();
      this.$parent.closeAddEdit();
    },
  },
};
</script>

<style lang="less" scoped>
.demo-ruleForm {
  width: 95%;
  margin: 0 auto;
  padding-top: 10px;
}
</style>
